/**
 * @ClassName LC50
 * @Author ykx
 * @Date 2024/3/7 10:27
 * @Version 1.0
 */
public class LC50 {
    public double myPow(double x, int n) {
        if (x == 1) {
            return 1;
        }

        double result = 1.0;
        if (n > 0) {
            for (int i = 0; i < n; i++) {
                result = result * x;
            }
        }

        if (n < 0) {
            for (int i = n; i < 0; i++) {
                result = result / x;
            }
        }

        return result;
    }
}
